<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Xppass Administrator's Control Panel</title>
<LINK href="<?php echo $www_site_url?>/public/yav-style.css" type=text/css rel=stylesheet>
<script src="<?php echo $www_site_url?>/public/js/common.js" type="text/javascript"></script>
<script src="<?php echo $www_site_url?>/public/js/ajax.js" type="text/javascript"></script>
<script src="<?php echo $www_site_url?>/public/js/calendar.js" type="text/javascript"></script>

<script>
function checkOnSubmit(formName) {

	var url = "<?php echo $www_site_url?>/admin.php";
	var params = mini.form.serialize($(formName));

	mini.ajax.post(url, function(r){

		var r = eval('(' + r + ')');

		if(r.s==200){
			alert(r.m);
			$('msg').innerHTML = r.m;
			history.go(-1);
		}
		if(r.s==400){
			alert(r.m);
			$('msg').innerHTML = r.m;
		}
	}, params);

	return false;

}
function getBrand(c_id){

/**** 清除所有的选择项 start ****/
/* Added by Wendy 2010.10.14 */
//清除品牌选项
var selobj = $('brand_container');
//var slbrad = document.getElementById('brand_container');
for(var i in selobj.options){
	//selobj.remove(i);
	selobj.options[i] = null;//IE不支持此方式
	}

//清除分店选项
var selobj1 = $('store_container');
for(var i in selobj1.options){
	//selobj1.remove(i);
	selobj1.options[i] = null;
	}
/**** 清除所有的选择项 end ****/


	if(c_id==''){
		selobj.options[0] = new Option('--', '');
		selobj1.options[0] = new Option('--', '');
		return ;
	}
	var url = "<?php echo $www_site_url?>/admin.php?action=corporation&view=ajaxbrand&c_id="+c_id;

	mini.ajax.get(url, function(r){

		var r = eval('(' + r + ')');
		var selobj = $('store_container');
		selobj.options[0] = new Option('--', '');

		if(r.s==200){
			var obj = eval('(' + r.d + ')');
			var selobj = $('brand_container');
			j=1;
			if(obj != ''){
				for(var i in obj){
					//if(i==0) selobj.options[0] = new Option(obj[i].cs_name, obj[i].cs_id) //replace 1st option with a new one
					selobj.options[j]=new Option(obj[i].b_name,obj[i].b_id) //add a new option to the end of SELECT
					j++;
				}
			}
			else{
				selobj.options[0] = new Option('--', '');
			}

		}
		if(r.s==400){
			$('msg').innerHTML = r.m;
		}
	});

	return false;
}
function getStore(b_id){

/**** 清除所有的选择项 start ****/
/* Added by Wendy 2010.10.14 */
var selobj = $('store_container');
for(var i in selobj.options){
	//selobj.remove(i);
	selobj.options[i] = null;//IE不支持此方式
	}
/**** 清除所有的选择项 end ****/

	if(b_id==''){
		selobj.options[0] = new Option('--', '');
		return ;
	}
	var url = "<?php echo $www_site_url?>/admin.php?action=corporation&view=ajaxstore&b_id="+b_id;

	mini.ajax.get(url, function(r){

		var r = eval('(' + r + ')');

		if(r.s==200){
			var obj = eval('(' + r.d + ')');
			var selobj = $('store_container');
			if(obj != ''){
				for(var i in obj){
					//if(i==0) selobj.options[0] = new Option(obj[i].cs_name, obj[i].cs_id) //replace 1st option with a new one
					selobj.options[i]=new Option(obj[i].cs_abbr+' '+obj[i].cs_name, obj[i].cs_id) //add a new option to the end of SELECT
				}
			}
			else{
				selobj.options[0] = new Option('--', '');
			}

		}
		if(r.s==400){
			$('msg').innerHTML = r.m;
		}
	});

	return false;
}

</script>
</head>
<body><div id="append"></div>
<div id="msg" style="color:red;text-align:center"></div>
	<div class="container">

		<div class="hastabmenu">
				<ul class="tabmenu">
					<li id="addassignmentbtn" class="tabcurrent"><a href="#"><?php echo lang('edit_assignment')?></a></li>
				</ul>
				<div id="addassignmentdiv" class="tabcontentcur" style="display:;">
					<form id="addassignmentform" name="addassignmentform" action="<?php echo $www_site_url?>/admin.php" method="post" onsubmit="return checkOnSubmit('addassignmentform');" >
					<input type="hidden" name="action" value="assignment">
					<input type="hidden" name="op" value="update">
					<input type="hidden" name="a_id" value="<?php echo $info['a_id'];?>">

					<table width="100%">
						<tr>
							<td width="10%"><?php echo lang('a_title')?>:</td>
							<td><input type="text" name="a_title" class="textfield" style="width:500px;" value="<?php echo $info['a_title'];?>" /> *<input type="button" value="Split" onclick="document.addassignmentform.a_title.value+='&lt;!--!--&gt;';"></td>
						</tr>


						<tr>
							<td><?php echo lang('a_sdate')?>:</td>
							<td><input type="text" name="a_sdate" onclick="showcalendar();" class="textfield" value="<?php echo $info['a_sdate'];?>" /></td>
						</tr>
						<tr>
							<td><?php echo lang('a_edate')?>:</td>
							<td><input type="text" name="a_edate" onclick="showcalendar();" class="textfield" value="<?php echo $info['a_edate'];?>"/></td>
						</tr>
						<tr>
							<td><?php echo lang('cs_corpration')?>:</td>
							<td><select name="c_id" onchange="getBrand(this.options[this.selectedIndex].value);">
							<option value="">--</option>
							<?php foreach ($corps as $v){?>
							<option value="<?php echo $v['c_id'];?>"  <?php if($v['c_id']==$info['c_id']) echo 'selected';?> ><?php echo $v['c_initial']." ". $v['c_title'];?></option>
							<?php } ?>
							</select></td>
						</tr>
						<tr>
							<td><?php echo lang('b_name')?>:</td>
							<td><select id="brand_container" name="b_id" onchange="getStore(this.options[this.selectedIndex].value);">
							<option value="">--</option>
							<?php foreach ($brands as $v){?>
							<option value="<?php echo $v['b_id'];?>"  <?php if($v['b_id']==$info['b_id']) echo 'selected';?> ><?php echo splitx($v['b_name']);?></option>
							<?php } ?>
							</select></td>
						</tr>
						<tr>
								<td><?php echo lang('cs_name')?>:</td>
							<td><select id="store_container" name="cs_id">
							<option value="<?php echo $info['cs_id'];?>"><?php echo $info['cs_abbr']." ".$info['cs_name'];?></option>
							</select></td>
						</tr>
						<tr>
							<td><?php echo lang('report')?>:</td>
							<td><select id="report" name="re_id">
							<option value="">--</option>
							<?php foreach ($reports as $v){?>
							<option value="<?php echo $v['re_id'];?>" <?php if($v['re_id']==$info['re_id']) echo 'selected';?>><?php echo $v['re_title'];?></option>
							<?php } ?>
							</select></td>
						</tr>

						<tr>
							<td><?php echo lang('a_hasphoto')?>:</td>
							<td><input type="checkbox" name="a_hasphoto" value="1" <?php if($info['a_hasphoto']==1) echo 'checked';?>/></td>
						</tr>

						<tr>
							<td><?php echo lang('a_hasaudio')?>:</td>
							<td><input type="checkbox" name="a_hasaudio" value="1" <?php if($info['a_hasaudio']==1) echo 'checked';?>/></td>
						</tr>
						<tr>
							<td><?php echo lang('a_desc')?>:</td>
							<td><textarea type="text" name="a_desc" rows="10" style="width:500px" class="textfield"/><?php echo $info['a_desc'];?></textarea><input type="button" value="Split" onclick="document.addassignmentform.a_desc.value+='&lt;!--!--&gt;';"></td>
						</tr>
						<tr>
							<td><?php echo lang('a_demand')?>:</td>
							<td><textarea type="text" name="a_demand" rows="10" style="width:500px" class="textfield"/><?php echo $info['a_demand'];?></textarea><input type="button" value="Split" onclick="document.addassignmentform.a_demand.value+='&lt;!--!--&gt;';"></td>
						</tr>
						<tr>
							<td><?php echo lang('istest')?>:</td>
							<td><input type="checkbox" name="a_istest" value="1" <?php if($info['a_istest']==1) echo 'checked';?>/></td>
						</tr>
						<tr>
							<td><?php echo lang('a_quiz')?>:</td>
							<td>格式说明,每一行输入一个测试题目。格式为 title:问题标题|A:答案|B:答案|C:答案|D:答案|answer:D
							<textarea type="text" name="a_quiz" rows="10" style="width:900px" class="textfield"/><?php echo $info['a_quiz'];?></textarea><input type="button" value="Split" onclick="document.addassignmentform.a_quiz.value+='&lt;!--!--&gt;';"></td>
						</tr>
						<tr>
						<td><?php echo lang('markgrade')?>:</td>
						<td>
						<input type="radio" name="a_markgrade" value="10" <?php if($info['a_markgrade']==10) echo 'checked';?> />0~10
						<input type="radio" name="a_markgrade" value="5" <?php if($info['a_markgrade']==5) echo 'checked';?> />0~5
						<input type="radio" name="a_markgrade" value="4" <?php if($info['a_markgrade']==4) echo 'checked';?> />0~4
						<input type="radio" name="a_markgrade" value="2" <?php if($info['a_markgrade']==2) echo 'checked';?> />0~2
						</td>
						</tr>

						<tr>

							<td colspan="2"><input type="submit" value="<?php echo lang('submit')?>" class="button"/>  <input type="button" value="<?php echo lang('goback')?>" onclick="history.go(-1);" class="button" /></td>
						</tr>
					</table>
					</form>

				</div>
		</div>
</div>

</body>
</html>